import axios from "axios";

// 登录
export interface LoginData {
    account: string;
    password: string;
    channel: string;
    host: string;
}

export function userLogin(data: LoginData) {
    return axios.post("/chat-api/user/login/password", data);
}

// 灵感广场
export interface DrawingPageParams {
    pageNo: number;
    pageSize: number;
    question: string;
    categoryCode: string;
}

export interface DrawingPageQuestionData {
    id: string;
    question: string;
    prompt: string;
    imageUrl: string;
    feature: string;
}
export interface DrawingPageCategoryData {
    code: string;
    name: string;
}

export interface DrawingPageData {
    categorys: DrawingPageCategoryData[],
    robotQuestions: DrawingPageQuestionData[],
    total: number
}

export function drawingPage(params: DrawingPageParams) {
    return axios.get<DrawingPageData>("/chat-api/robotQuestion/drawingPage", { params });
}

// 绘画任务
export interface TaskPageParams {
    pageNo: number;
    pageSize: number;
    type: number;
    queryTime: string;
    taskType: number;
}

export function taskPage(params: TaskPageParams) {
    return axios.get("/chat-api/chatGallery/task/page", { params });
}

// 绘画操作
export function listDrawingFixedRobot() {
    return axios.get("/chat-api/robot/listDrawingFixedRobot");
}

// 绘画设置
export function drawingLimit() {
    return axios.get("/chat-api/myLimit/drawingLimit");
}

// 绘画进行中
export function taskRunning() {
    return axios.get("/chat-api/midjourney/task/list/running");
}

// 开始创作
// {
//     "path": "imagine",
//     "promptText": "测试",
//     "prompt": "测试",
//     "promptEn": "test",
//     "command": " --ar 1:1 --niji 6",
//     "base64": "",
//     "base64Array": [],
//     "drawingType": "Drawing_Fast",
//     "dimensions": "",
//     "sourceFile": null,
//     "targetFile": null,
//     "sourceImgUrl": null,
//     "targetImgUrl": null,
//     "applicationCode": null,
//     "srefImages": [],
//     "chatChannel": "Web_Chat"
// }
// {
//     "path": "imagine",
//     "promptText": "测试d",
//     "prompt": "测试d",
//     "promptEn": "Test d",
//     "command": " --ar 1:1 --niji 6",
//     "base64": "",
//     "base64Array": [],
//     "drawingType": "Drawing_Relaxed",
//     "dimensions": "",
//     "sourceFile": null,
//     "targetFile": null,
//     "sourceImgUrl": null,
//     "targetImgUrl": null,
//     "applicationCode": null,
//     "srefImages": [],
//     "chatChannel": "Web_Chat"
// }

export interface CreateImage {
    path: string;
    promptText: string;
    prompt: string;
    promptEn: string;
    command: string;
    base64: string;
    base64Array: string[];
    drawingType: string;
    dimensions: string;
    sourceFile: string;
    targetFile: string;
    sourceImgUrl: string;
    targetImgUrl: string;
    applicationCode: string;
    srefImages: [];
    chatChannel: string;
}


export function createImage(data: CreateImage) {
    return axios.post("/chat-api/midjourney/submit/imagine", data);
}

// 查询绘画结果
export function fetchTask(params: { taskIds: string }) {
    return axios.get("/chat-api/midjourney/task/fetchByIds", { params });
}


// 中文转英文
export function zhToEn(params: { text: string }) {
    return axios.get("/chat-api/translate/zhToEn", { params });
}

// AI联想
export function aiCreate(data: { prompt: string }) {
    return axios.post("/chat-api/chatComplete/send/mjPrompt", data);
}

export function upload(data: FormData) {
    return axios.post("/chat-api/upload/imageBatch", data, {
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
}
